package com.legendshop.openportal.sdk.model.request;

import com.legendshop.openportal.sdk.annotation.JsonValid;
import com.legendshop.openportal.sdk.model.BaseRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

import static com.legendshop.openportal.sdk.model.constants.ApiPathConstants.QUERY_PROD_PROMISE;

/**
 * @Description: 查询配送预计送达时间
 **/
@Data
@Accessors(chain = true)
public class ProdPromiseInfoRequest extends BaseRequest {

    private static final long serialVersionUID = 8187695740776417325L;

    /**
     *
     * 格式是 {“prodId”:商品编号1,“skuId”:规格编号1,”num”:商品数量1}
     *
     */
    @NotBlank(message = "sku对象不能为空")
    @JsonValid(target = ProdPromiseInfoRequest.SkuInfo.class, isArrayJson = false, message = "skuInfo不是json类型字段,格式是{“prodId”:商品编号1,“skuId”:规格编号1,”num”:商品数量1}")
    @ApiModelProperty("skuInfo不是json类型字段,格式是{“prodId”:商品编号1,“skuId”:规格编号1,”num”:商品数量1}")
    private String skuInfo;

    /**
     * 非空：是
     * 一级地址
     */
    @ApiModelProperty("一级地址")
    @NotNull(message = "一级地址不能为空")
    private Long province;

    /**
     * 非空：是
     * 二级地址
     */
    @ApiModelProperty("二级地址")
    @NotNull(message = "二级地址不能为空")
    private Long city;

    /**
     * 非空：是
     * 三级地址
     */
    @ApiModelProperty("三级地址")
    @NotNull(message = "三级地址不能为空")
    private Long area;

    /**
     * 非空：是
     * 四级地址  (如果该地区有四级地址，则必须传递四级地址，没有四级地址则传0)
     */
    @ApiModelProperty("四级地址")
    @NotNull(message = "四级地址不能为空")
    private Long town;


    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class SkuInfo implements Serializable {
        private static final long serialVersionUID = -8498370741983699232L;

        @NotNull(message = "产品Id不能为空")
        @ApiModelProperty(value = "产品Id")
        private Long prodId;

        @NotNull(message = "sku编码不能为空")
        @ApiModelProperty(value = "sku编码")
        private Long skuId;

        @ApiModelProperty("下单数量")
        @NotNull(message = "商品数量不能为空")
        private Integer num;

    }


    @Override
    @ApiModelProperty(hidden = true)
    public String getApiPath() {
        return QUERY_PROD_PROMISE;

    }
}
